function Write-DataTable
{
   param($tableName, $dt,$connectionName)

    if ($dt)
    {
        try
        {
            $bulkCopy = new-object ("Data.SqlClient.SqlBulkCopy") $Script:SqlClientConnString
            $bulkCopy.DestinationTableName = $tableName
            $bulkCopy.BatchSize = 50000
            $bulkCopy.BulkCopyTimeout = 0
            $bulkCopy.WriteToServer($dt)
        }
        catch
        {
            $ex = $_.Exception
            Write-LogMessage -Source 'Write-DataTable' -Message "$($connectionName):$ex.Message"
            Write-Error "Write-DataTable  $($connectionName):$ex.Message"
            continue
        }
    }
}
